{% block sw_data_grid_slot_pagination %}
<sw-pagination
    v-bind="{ page, limit, total, steps }"
    :total-visible="7"
    @page-change="paginate"
/>
{% endblock %}

{% block sw_data_grid_bulk_selected_actions_content %}
{% block sw_data_grid_bulk_edit_content %}
<a
    v-if="allowBulkEdit"
    class="link link-primary"
    role="button"
    tabindex="0"
    @click="onClickBulkEdit"
    @keydown.enter="onClickBulkEdit"
>
    {{ $tc('global.sw-bulk-edit-modal.bulkEdit') }}
</a>
{% endblock %}

{% block sw_data_grid_bulk_delete_content %}
<a
    v-if="allowDelete"
    class="link link-danger"
    role="button"
    tabindex="0"
    @click="showBulkDeleteModal = true"
    @keydown.enter="showBulkDeleteModal = true"
>
    {{ $tc('global.default.delete') }}
</a>
{% endblock %}

<slot
    name="bulk-additional"
    v-bind="{ selectionCount }"
></slot>
{% endblock %}

{% block sw_data_grid_slot_bulk_modals %}
{% block sw_data_grid_bulk_edit_modal %}
<slot
    name="bulk-edit-modal"
    v-bind="{ selection }"
>
    {% block sw_data_grid_slot_bulk_edit_modal %}
    <sw-bulk-edit-modal
        v-if="showBulkEditModal"
        :selection="selection"
        :bulk-grid-edit-columns="bulkGridEditColumns"
        @modal-close="onCloseBulkEditModal"
    />
    {% endblock %}
</slot>
{% endblock %}

{% block sw_data_grid_bulk_delete_modal %}
<sw-modal
    v-if="showBulkDeleteModal"
    class="sw-entity-listing__confirm-bulk-delete-modal"
    variant="small"
    :title="$tc('global.default.warning')"
    @modal-close="showBulkDeleteModal = false"
>
    <p class="sw-data-grid__confirm-bulk-delete-text">
        <slot
            name="bulk-modal-delete-confirm-text"
            v-bind="{ selectionCount }"
        >
            {{ $tc('global.entity-components.deleteMessage', { count: selectionCount }, selectionCount) }}
        </slot>
    </p>

    <template #modal-footer>
        <slot name="bulk-modal-cancel">
            <mt-button
                size="small"
                variant="secondary"
                @click="showBulkDeleteModal = false"
            >
                {{ $tc('global.default.cancel') }}
            </mt-button>
        </slot>

        <slot
            name="bulk-modal-delete-items"
            v-bind="{ isBulkLoading, deleteItems }"
        >
            <mt-button
                variant="critical"
                size="small"
                :is-loading="isBulkLoading"
                @click="deleteItems"
            >
                {{ $tc('global.default.delete') }}
            </mt-button>
        </slot>
    </template>
</sw-modal>
{% endblock %}

<slot
    name="bulk-modals-additional"
    v-bind="{ selection, ids: Object.keys(selection) }"
></slot>
{% endblock %}

{% block sw_data_grid_slot_actions %}
<slot
    name="detail-action"
    v-bind="{ item }"
>
    <sw-context-menu-item
        v-if="detailRoute"
        v-tooltip="{
            message: $tc('sw-privileges.tooltip.warning'),
            disabled: allowEdit || allowView,
            showOnDisabledElements: true,
            zIndex: 9050,
        }"
        class="sw-entity-listing__context-menu-edit-action"
        :disabled="(!allowEdit && !allowView) || undefined"
        :router-link="{ name: detailRoute, params: { id: item.id } }"
    >
        {{ detailPageLinkText }}
    </sw-context-menu-item>
</slot>

<slot
    name="more-actions"
    v-bind="{ item }"
></slot>

<slot
    name="delete-action"
    v-bind="{ item, showDelete, allowDelete }"
>
    <sw-context-menu-item
        v-tooltip.bottom="{
            message: $tc('sw-privileges.tooltip.warning'),
            disabled: allowDelete,
            showOnDisabledElements: true,
            zIndex: 9050,
        }"
        :disabled="!allowDelete || undefined"
        class="sw-entity-listing__context-menu-edit-delete"
        variant="danger"
        @click="showDelete(item.id)"
    >
        {{ $tc('global.default.delete') }}
    </sw-context-menu-item>
</slot>
{% endblock %}

{% block sw_data_grid_slot_action_modals %}
<sw-modal
    v-if="deleteId === item.id"
    :title="$tc('global.default.warning')"
    variant="small"
    @modal-close="closeModal"
>
    <p class="sw-listing__confirm-delete-text">
        <slot
            name="delete-confirm-text"
            v-bind="{ item }"
        >
            {{ $tc('global.entity-components.deleteMessage') }}
        </slot>
    </p>

    <template #modal-footer>
        <slot
            name="delete-modal-footer"
            v-bind="{ item }"
        >
            <slot
                name="delete-modal-cancel"
                v-bind="{ item }"
            >
                <mt-button
                    size="small"
                    variant="secondary"
                    @click="closeModal"
                >
                    {{ $tc('global.default.cancel') }}
                </mt-button>
            </slot>

            <slot
                name="delete-modal-delete-item"
                v-bind="{ item }"
            >
                <mt-button
                    variant="critical"
                    size="small"
                    @click="deleteItem(item.id)"
                >
                    {{ $tc('global.default.delete') }}
                </mt-button>
            </slot>
        </slot>
    </template>
</sw-modal>
{% endblock %}
